package com.springboot.demo.service;

import com.springboot.demo.entity.ReaderFine;
import com.springboot.demo.entity.ReaderFineRecord;
import com.springboot.demo.mapper.ReaderFineRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * @author 17069120036-汪轶辉-974319097@qq.com
 * @date 2020/4/24
 */
@Service
public class ReaderFineRecordService {
    @Autowired
    ReaderFineRecordMapper readerFineRecordMapper;
    public List<ReaderFineRecord> getReaderFineRecordByPhone(String phonenum)throws UnsupportedEncodingException{
        String phone=new String(phonenum.getBytes("8859_1"), "utf8");
        List<ReaderFineRecord> list=readerFineRecordMapper.getReaderFineRecordByPhone(phone);
        return list;
    }

    public List<ReaderFine> getReaderFineByPhone(String phonenum)throws UnsupportedEncodingException{
        String phone=new String(phonenum.getBytes("8859_1"), "utf8");
        List<ReaderFine> list=readerFineRecordMapper.getReaderFineByPhone(phone);
        return list;
    }

    public void insertReaderFineRecord(String phone, String rname, long bookId, String bname, String starttime, String endtime, int fine) {
        readerFineRecordMapper.insertReaderFineRecord(phone, rname, bookId, bname, starttime, endtime, fine);
    }
    public void payReaderFine(String phone, String startTime) {
        readerFineRecordMapper.payReaderFine(phone, startTime);
    }
}
